package com.thjk.bdf.preloan.web.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.thjk.bdf.preloan.web.interceptor.SessionInterptor;


/**
 * @author admin
 *
 */
@Configuration
public class InterptorConfig implements WebMvcConfigurer{
	
	@Autowired
	private SessionInterptor sessionInterptor;
	
	/**
	 * 功能描述: 配置静态资源,避免静态资源请求被拦截
	 * @param registry
	 */
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("favicon.ico").addResourceLocations("classpath:/static/favicon.ico");
		registry.addResourceHandler("ajax_tpl/**").addResourceLocations("classpath:/static/ajax_tpl/");
		registry.addResourceHandler("css/**").addResourceLocations("classpath:/static/css/");
		registry.addResourceHandler("fonts/**").addResourceLocations("classpath:/static/fonts/");
		registry.addResourceHandler("img/**").addResourceLocations("classpath:/static/img/");
		registry.addResourceHandler("js/**").addResourceLocations("classpath:/static/js/");
		registry.addResourceHandler("vendor/**").addResourceLocations("classpath:/static/vendor/");
    }
	
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(sessionInterptor)
        .addPathPatterns("/**").excludePathPatterns("/css/**","/js/**","/vendor/**","/img/**","/fonts/**")
		.excludePathPatterns("/error","/ajaxAccountQuickLoginSignsms","/accountQuickLogin");
//		.excludePathPatterns("/accout", "/validateAgain", "/ajax_tpl/**", "/getCaptcha", "/userValidate");
//		.addPathPatterns("/**").excludePathPatterns("/home");
		
		//人脸核身拦截器
//	    registry.addInterceptor(faceVerifyInterceptor)
//	    .addPathPatterns("/toPbccrcLogin")
//	    .addPathPatterns("/creditApplyFirst")
//	    .addPathPatterns("/toUseApply");;
	}
}
